# -*-coding: utf-8 -*-
import urllib

alex_url = 'http://whois.alexa.cn/whois.php?server=whois.paycenter.com.cn&who='

with open('17.txt', 'rb') as file_obj_1, open('result.txt', 'wb') as file_obj_2:
    domain_264 = set([_.replace('\r\n', '').lower() for _ in file_obj_1])

for domain in domain_264:
    req = urllib.urlopen(alex_url + domain)
    response = req.read()
    try:
        for item in response.split('<br />\n'):
            if item.find('Domain Status:') >= 0:
                status = item.replace('Domain Status:', '')
            elif item.find('Registrar:') >= 0:
                registrar = item.replace('Registrar:', '')
            elif item.find('Creation Date:') >= 0:
                create_date = item.replace('Creation Date:', '')
            elif item.find('Registrar Registration Expiration Date:') >= 0:
                expire_date = item.replace('Registrar Registration Expiration Date:', '')
        print domain, status, registrar, create_date, expire_date
        print '\n'
    except:
        pass
